# 入口文件
import json
import os
import tornado.ioloop
import tornado.web
from tornado.options import define,options
from app.base import BaseHandler

# 定义端口号
define("port",default=8000,help='default port',type=int)

# 定义具体静态目录
static_path = os.path.join(os.path.dirname(__file__),"static")


class TestHandler(BaseHandler):
    async def get(self):
        self.finish({
            'msg':'你好tornado',
            'code':200
        })


# 路由
urlpatterns = [(r'/',TestHandler)]


# 实例化对象
app = tornado.web.Application(handlers=urlpatterns,static_path=static_path,debug=True)

if __name__ == '__main__':
    # 开启事件循环
    print("tornado服务启动")

    tornado.options.parse_command_line()

    app.listen(options.port)

    tornado.ioloop.IOLoop.instance().start()
